define(['app'],function(app){return {module: function($scope, $http, eventBusService, httpService, params) {

	$scope.form.floor = 0;
	$scope.form.task_num = 1;
	$scope.form.class_capacity = 0;
	$scope.form.exam_capacity = 0;
	$scope.form.max_capacity = 0;

	//查询主校区和分校区
	httpService.post(app.urls.unit_selectSchoolAndAttach,{"fk_unit":"self"},function(data){
		if("0000" === data.code){
			$scope.unitList = data.data;
		}else{
			alert(data.msg);
		}
	});

	//教室类型
	httpService.post(app.urls.dictionary_selectByRule,{fk_rule:"f5e97731-54fb-44e4-8f6c-1137a095aa1f"},function(data){
		if("0000" === data.code){
			$scope.typeList = data.data;
		}else{
			alert(data.msg);
		}
	});

	$scope.findBuilding = function() {
		httpService.post(app.urls.building_select, {"fk_unit": $scope.form.fk_unit}, function (data) {
			if ("0000" === data.code) {
				$scope.buildingList = data.data;
			} else {
				alert(data.msg);
			}
		});
	}

	$scope.saveForm = function(){
		if($scope.formCheck()){

			httpService.post(app.urls.classroom_insert,$scope.form,function(data){
				if("0000" === data.code){
					eventBusService.publish("content.page.reload", data);
					eventBusService.publish("modal.page.close", {});
	    		}else{
	    			alert(data.msg);
	    		}
			});
		}
	}
}}});